/**
 * setupStores
 */

import type { App } from "vue";
import type { LaunchOptions } from "@sfx-lib/core";
import type { InitStoreOptions } from "@sfx-vue-lib/common";

import { defaultStorage } from "@sfx-lib/core";
import { useTestStore, setupPinia } from "@sfx-vue-lib/stores";

/**
 * 设置存储
 * @param app
 * @param options
 * @description 配置存储的 ID
 */
async function setupStores(app: App, options: LaunchOptions) {
    //
    const { workspace } = options;
    const initStoreOptions: InitStoreOptions = { workspace: workspace };
    // call the core function
    setupPinia(app, initStoreOptions);

    {
        // ===TEST
        const testStore = useTestStore();
        // testStore.setToken("new-test-store-23");
        const storeId3 = `${workspace}-${testStore.$id}`;
        const x = defaultStorage.getItem(storeId3);
        // console.log(x);
    }
}

export { setupStores, setupStores as default };
